package com.txd.mofa.shouye.fgt;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.kongzue.baseframework.interfaces.Layout;
import com.txd.mofa.R;
import com.txd.mofa.adapter.ShipinBofangAdapter;
import com.txd.mofa.base.BaseFgt;
import com.txd.mofa.net.NetUtils;
import com.txd.mofa.view.MyJzvdStd;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Layout(R.layout.fgt_shipin)
public class ShipinFgt extends BaseFgt {

    private MyJzvdStd myJzvdStd;
    private ShipinBofangAdapter shipinBofangAdapter;
    private List<Map<String, String>> list;
    private LinearLayout ll;

    public static ShipinFgt newInstance() {

        Bundle args = new Bundle();

        ShipinFgt fragment = new ShipinFgt();
        fragment.setArguments(args);
        return fragment;
    }

    @SuppressLint("WrongConstant")
    @Override
    public void initViews() {
        super.initViews();
        myJzvdStd = findViewById(R.id.mp_video);
        ll = findViewById(R.id.ll);

//        recyclerView.setOnFlingListener(null);
//        PagerSnapHelper snapHelper = new PagerSnapHelper();
//        snapHelper.attachToRecyclerView(recyclerView);
//
//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(me);
//        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
//        recyclerView.setLayoutManager(linearLayoutManager);
//
//        shipinBofangAdapter = new ShipinBofangAdapter(R.layout.item_page2);
//        recyclerView.setAdapter(shipinBofangAdapter);
//
//        list = new ArrayList<>();
//        for (int i = 0; i < 16;i++){
//            Map<String,String> map = new HashMap<>();
//            map.put("flag","111");
//            map.put("video_url","http://vjs.zencdn.net/v/oceans.mp4");
//            list.add(map);
//        }
//        shipinBofangAdapter.setNewData(list);



//        if (item.get("flag") != null){
//            if (item.get("flag").equals("111")){
        myJzvdStd.setUp("http://vjs.zencdn.net/v/oceans.mp4", "");
//                if (helper.getPosition() == 0) {
        myJzvdStd.startVideo();
//                }
//                jzvdStd.thumbImageView.setImageResource(R.mipmap.test);
                Glide.with(me).load(R.mipmap.test4).into(myJzvdStd.thumbImageView);
        myJzvdStd.thumbImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);


        DisplayMetrics dm2 = getResources().getDisplayMetrics();
        System.out.println("heigth2 : " + dm2.heightPixels);
        System.out.println("width2 : " + dm2.widthPixels);

        ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,dm2.heightPixels));

    }

    @Override
    protected void onNetworkConnected(NetUtils.NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    public void setEvents() {

    }

    @Override
    public void onLazyLoad() {

    }


}
